home *** CD-ROM | disk | FTP | other *** search
/ Motor Sport Digital Archive Collection 1960s / Motor Sport Digital Archive Collection 1960s.iso / main.swf / scripts / mx / core / Repeater.as < prev    next >
Encoding:
Text File  |  2008-05-21  |  31.3 KB  |  1,003 lines

  1. package mx.core
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.events.Event;
  5.    import flash.system.ApplicationDomain;
  6.    import mx.automation.IAutomationObject;
  7.    import mx.collections.ArrayCollection;
  8.    import mx.collections.CursorBookmark;
  9.    import mx.collections.ICollectionView;
  10.    import mx.collections.IList;
  11.    import mx.collections.IViewCursor;
  12.    import mx.collections.ItemResponder;
  13.    import mx.collections.ListCollectionView;
  14.    import mx.collections.XMLListCollection;
  15.    import mx.collections.errors.ItemPendingError;
  16.    import mx.events.CollectionEvent;
  17.    import mx.events.CollectionEventKind;
  18.    import mx.events.FlexEvent;
  19.    import mx.resources.ResourceBundle;
  20.    
  21.    use namespace mx_internal;
  22.    
  23.    public class Repeater extends UIComponent implements IRepeater
  24.    {
  25.       private static var resourceNotExecuting:String;
  26.       
  27.       mx_internal static const VERSION:String = "2.0.1.0";
  28.       
  29.       private static var packageResources:ResourceBundle = ResourceBundle.getResourceBundle("core",ApplicationDomain.currentDomain);
  30.       
  31.       loadResources();
  32.       
  33.       private var _count:int = -1;
  34.       
  35.       mx_internal var createdComponents:Array;
  36.       
  37.       public var childDescriptors:Array;
  38.       
  39.       private var iterator:IViewCursor;
  40.       
  41.       private var _currentIndex:int;
  42.       
  43.       private var _startingIndex:int = 0;
  44.       
  45.       private var collection:ICollectionView;
  46.       
  47.       private var descriptorIndex:int;
  48.       
  49.       private var created:Boolean = false;
  50.       
  51.       private var _container:Container;
  52.       
  53.       private var _recycleChildren:Boolean = false;
  54.       
  55.       public function Repeater()
  56.       {
  57.          created = false;
  58.          _count = -1;
  59.          _recycleChildren = false;
  60.          _startingIndex = 0;
  61.          super();
  62.       }
  63.       
  64.       private static function loadResources() : void
  65.       {
  66.          resourceNotExecuting = packageResources.getString("notExecuting");
  67.       }
  68.       
  69.       private function responderFaultHandler(param1:Object, param2:Object) : void
  70.       {
  71.       }
  72.       
  73.       private function removeAllChildRepeaters(param1:Container) : void
  74.       {
  75.          var _loc2_:int = 0;
  76.          var _loc3_:int = 0;
  77.          var _loc4_:Repeater = null;
  78.          if(param1.mx_internal::childRepeaters)
  79.          {
  80.             _loc2_ = int(param1.mx_internal::childRepeaters.length);
  81.             _loc3_ = _loc2_ - 1;
  82.             while(_loc3_ >= 0)
  83.             {
  84.                _loc4_ = param1.mx_internal::childRepeaters[_loc3_];
  85.                if(hasDescendant(_loc4_))
  86.                {
  87.                   removeRepeater(_loc4_);
  88.                }
  89.                _loc3_--;
  90.             }
  91.          }
  92.       }
  93.       
  94.       [Bindable("nextRepeaterItem")]
  95.       public function get currentItem() : Object
  96.       {
  97.          var result:Object = null;
  98.          if(_currentIndex == -1)
  99.          {
  100.             throw new Error(resourceNotExecuting);
  101.          }
  102.          if(iterator)
  103.          {
  104.             try
  105.             {
  106.                iterator.seek(CursorBookmark.FIRST,_currentIndex);
  107.                result = iterator.current;
  108.             }
  109.             catch(itemPendingError:ItemPendingError)
  110.             {
  111.                itemPendingError.addResponder(new ItemResponder(responderResultHandler,responderFaultHandler));
  112.             }
  113.          }
  114.          return result;
  115.       }
  116.       
  117.       private function collectionChangedHandler(param1:CollectionEvent) : void
  118.       {
  119.          switch(param1.kind)
  120.          {
  121.             case CollectionEventKind.UPDATE:
  122.                break;
  123.             default:
  124.                execute();
  125.          }
  126.       }
  127.       
  128.       private function getIndexForFirstChild() : int
  129.       {
  130.          var _loc1_:LocationInfo = null;
  131.          var _loc2_:int = 0;
  132.          var _loc3_:Array = null;
  133.          var _loc4_:int = 0;
  134.          var _loc5_:IFlexDisplayObject = null;
  135.          var _loc6_:Repeater = null;
  136.          _loc1_ = new LocationInfo();
  137.          _loc2_ = 0;
  138.          _loc3_ = container.mx_internal::createdComponents;
  139.          _loc4_ = !!_loc3_ ? int(_loc3_.length) : 0;
  140.          while(_loc2_ < _loc4_)
  141.          {
  142.             _loc5_ = container.mx_internal::createdComponents[_loc2_];
  143.             if(_loc5_ == this)
  144.             {
  145.                _loc1_.found = true;
  146.                break;
  147.             }
  148.             if(_loc5_ is Repeater)
  149.             {
  150.                _loc6_ = Repeater(_loc5_);
  151.                _loc6_.getIndexForRepeater(this,_loc1_);
  152.                if(_loc1_.found)
  153.                {
  154.                   break;
  155.                }
  156.             }
  157.             else
  158.             {
  159.                _loc1_.index += 1;
  160.             }
  161.             _loc2_++;
  162.          }
  163.          return _loc1_.found ? _loc1_.index : container.numChildren;
  164.       }
  165.       
  166.       private function removeRepeater(param1:Repeater) : void
  167.       {
  168.          param1.removeAllChildren(param1.container);
  169.          param1.removeAllChildRepeaters(param1.container);
  170.          removeChildRepeater(container,param1);
  171.          param1.deleteReferenceOnParentDocument(IFlexDisplayObject(parentDocument));
  172.          param1.dataProvider = null;
  173.       }
  174.       
  175.       private function updateItems(param1:int, param2:int) : void
  176.       {
  177.          var _loc3_:int = 0;
  178.          var _loc4_:int = 0;
  179.          var _loc5_:IRepeaterClient = null;
  180.          var _loc6_:int = 0;
  181.          if(recycleChildren)
  182.          {
  183.             _loc3_ = container.numChildren;
  184.             _loc4_ = 0;
  185.             while(_loc4_ < _loc3_)
  186.             {
  187.                _loc5_ = IRepeaterClient(container.getChildAt(_loc4_));
  188.                _loc6_ = getRepeaterIndex(_loc5_);
  189.                if(_loc6_ != -1 && param1 <= _loc6_ && _loc6_ <= param2)
  190.                {
  191.                   if(_loc5_ is IDeferredInstantiationUIComponent)
  192.                   {
  193.                      IDeferredInstantiationUIComponent(_loc5_).executeBindings(true);
  194.                   }
  195.                }
  196.                _loc4_++;
  197.             }
  198.          }
  199.          else
  200.          {
  201.             removeItems(param1,param2);
  202.             addItems(param1,param2);
  203.          }
  204.       }
  205.       
  206.       public function get container() : Container
  207.       {
  208.          return _container;
  209.       }
  210.       
  211.       private function createComponentFromDescriptor(param1:int, param2:int, param3:Boolean) : IFlexDisplayObject
  212.       {
  213.          var _loc4_:UIComponentDescriptor = null;
  214.          var _loc5_:IFlexDisplayObject = null;
  215.          _loc4_ = childDescriptors[param2];
  216.          if(!_loc4_.document)
  217.          {
  218.             _loc4_.document = document;
  219.          }
  220.          _loc4_.mx_internal::instanceIndices = !!instanceIndices ? instanceIndices : [];
  221.          _loc4_.mx_internal::instanceIndices.push(param1);
  222.          _loc4_.mx_internal::repeaters = repeaters;
  223.          _loc4_.mx_internal::repeaters.push(this);
  224.          _loc4_.mx_internal::repeaterIndices = repeaterIndices;
  225.          _loc4_.mx_internal::repeaterIndices.push(startingIndex + param1);
  226.          _loc4_.invalidateProperties();
  227.          _loc5_ = container.createComponentFromDescriptor(_loc4_,param3);
  228.          _loc4_.mx_internal::instanceIndices = null;
  229.          _loc4_.mx_internal::repeaters = null;
  230.          _loc4_.mx_internal::repeaterIndices = null;
  231.          dispatchEvent(new Event("nextRepeaterItem"));
  232.          return _loc5_;
  233.       }
  234.       
  235.       private function get numCreatedChildren() : int
  236.       {
  237.          var _loc1_:int = 0;
  238.          var _loc2_:int = 0;
  239.          var _loc3_:IFlexDisplayObject = null;
  240.          var _loc4_:Repeater = null;
  241.          _loc1_ = 0;
  242.          _loc2_ = 0;
  243.          while(_loc2_ < mx_internal::createdComponents.length)
  244.          {
  245.             _loc3_ = mx_internal::createdComponents[_loc2_];
  246.             if(_loc3_ is Repeater)
  247.             {
  248.                _loc4_ = Repeater(_loc3_);
  249.                _loc1_ += _loc4_.numCreatedChildren;
  250.             }
  251.             else
  252.             {
  253.                _loc1_ += 1;
  254.             }
  255.             _loc2_++;
  256.          }
  257.          return _loc1_;
  258.       }
  259.       
  260.       [Bindable("startingIndexChanged")]
  261.       public function get startingIndex() : int
  262.       {
  263.          return _startingIndex;
  264.       }
  265.       
  266.       override public function set showInAutomationHierarchy(param1:Boolean) : void
  267.       {
  268.       }
  269.       
  270.       public function set startingIndex(param1:int) : void
  271.       {
  272.          _startingIndex = param1;
  273.          execute();
  274.          dispatchEvent(new Event("startingIndexChanged"));
  275.       }
  276.       
  277.       private function recreate() : void
  278.       {
  279.          var _loc1_:int = 0;
  280.          var _loc2_:int = 0;
  281.          removeAllChildren(container);
  282.          removeAllChildRepeaters(container);
  283.          _loc1_ = container.numChildren;
  284.          _loc2_ = getIndexForFirstChild();
  285.          createComponentsFromDescriptors(true);
  286.          if(_loc1_ != _loc2_)
  287.          {
  288.             reindexDescendants(_loc1_,_loc2_);
  289.          }
  290.       }
  291.       
  292.       [Bindable("countChanged")]
  293.       public function get count() : int
  294.       {
  295.          return _count;
  296.       }
  297.       
  298.       private function adjustIndices(param1:IRepeaterClient, param2:int) : void
  299.       {
  300.          var _loc3_:Array = null;
  301.          var _loc4_:int = 0;
  302.          var _loc5_:int = 0;
  303.          _loc3_ = param1.repeaters;
  304.          if(_loc3_ == null)
  305.          {
  306.             return;
  307.          }
  308.          _loc4_ = int(_loc3_.length);
  309.          _loc5_ = 0;
  310.          while(_loc5_ < _loc4_)
  311.          {
  312.             if(_loc3_[_loc5_] == this)
  313.             {
  314.                param1.repeaterIndices[_loc5_] += param2;
  315.                param1.instanceIndices[_loc5_] += param2;
  316.                break;
  317.             }
  318.             _loc5_++;
  319.          }
  320.       }
  321.       
  322.       private function createComponentsFromDescriptors(param1:Boolean) : void
  323.       {
  324.          var _loc2_:int = 0;
  325.          var _loc3_:int = 0;
  326.          var _loc4_:int = 0;
  327.          var _loc5_:int = 0;
  328.          var _loc6_:IFlexDisplayObject = null;
  329.          dispatchEvent(new FlexEvent(FlexEvent.REPEAT_START));
  330.          mx_internal::createdComponents = [];
  331.          if(collection && collection.length > 0 && collection.length - startingIndex > 0)
  332.          {
  333.             _loc2_ = positiveMin(collection.length - startingIndex,count);
  334.             _loc3_ = 0;
  335.             while(_loc3_ < _loc2_)
  336.             {
  337.                _currentIndex = startingIndex + _loc3_;
  338.                dispatchEvent(new FlexEvent(FlexEvent.REPEAT));
  339.                if(Boolean(childDescriptors) && childDescriptors.length > 0)
  340.                {
  341.                   _loc4_ = int(childDescriptors.length);
  342.                   _loc5_ = 0;
  343.                   while(_loc5_ < _loc4_)
  344.                   {
  345.                      _loc6_ = createComponentFromDescriptor(_loc3_,_loc5_,param1);
  346.                      mx_internal::createdComponents.push(_loc6_);
  347.                      if(_loc6_ is IUIComponent)
  348.                      {
  349.                         IUIComponent(_loc6_).owner = this;
  350.                      }
  351.                      if(_loc6_ is IAutomationObject)
  352.                      {
  353.                         IAutomationObject(_loc6_).showInAutomationHierarchy = true;
  354.                      }
  355.                      _loc5_++;
  356.                   }
  357.                }
  358.                _loc3_++;
  359.             }
  360.             _currentIndex = -1;
  361.          }
  362.          dispatchEvent(new FlexEvent(FlexEvent.REPEAT_END));
  363.       }
  364.       
  365.       mx_internal function getItemAt(param1:int) : Object
  366.       {
  367.          var result:Object = null;
  368.          var index:int = param1;
  369.          if(iterator)
  370.          {
  371.             try
  372.             {
  373.                iterator.seek(CursorBookmark.FIRST,index);
  374.                result = iterator.current;
  375.             }
  376.             catch(itemPendingError:ItemPendingError)
  377.             {
  378.                itemPendingError.addResponder(new ItemResponder(responderResultHandler,responderFaultHandler));
  379.             }
  380.          }
  381.          return result;
  382.       }
  383.       
  384.       private function sort() : void
  385.       {
  386.          execute();
  387.       }
  388.       
  389.       public function get recycleChildren() : Boolean
  390.       {
  391.          return _recycleChildren;
  392.       }
  393.       
  394.       private function positiveMin(param1:int, param2:int) : int
  395.       {
  396.          var _loc3_:int = 0;
  397.          _loc3_ = 0;
  398.          if(param1 >= 0)
  399.          {
  400.             if(param2 >= 0)
  401.             {
  402.                if(param1 < param2)
  403.                {
  404.                   _loc3_ = param1;
  405.                }
  406.                else
  407.                {
  408.                   _loc3_ = param2;
  409.                }
  410.             }
  411.             else
  412.             {
  413.                _loc3_ = param1;
  414.             }
  415.          }
  416.          else
  417.          {
  418.             _loc3_ = param2;
  419.          }
  420.          return _loc3_;
  421.       }
  422.       
  423.       private function resetRepeaterIndices(param1:IRepeaterClient, param2:int) : void
  424.       {
  425.          var _loc3_:Array = null;
  426.          var _loc4_:Container = null;
  427.          var _loc5_:int = 0;
  428.          var _loc6_:int = 0;
  429.          var _loc7_:IRepeaterClient = null;
  430.          _loc3_ = param1.repeaterIndices;
  431.          _loc3_[_loc3_.length - 1] = param2;
  432.          param1.repeaterIndices = _loc3_;
  433.          if(param1 is Container)
  434.          {
  435.             _loc4_ = Container(param1);
  436.             _loc5_ = _loc4_.numChildren;
  437.             _loc6_ = 0;
  438.             while(_loc6_ < _loc5_)
  439.             {
  440.                _loc7_ = IRepeaterClient(_loc4_.getChildAt(_loc6_));
  441.                resetRepeaterIndices(_loc7_,param2);
  442.                _loc6_++;
  443.             }
  444.          }
  445.       }
  446.       
  447.       private function removeItems(param1:int, param2:int) : void
  448.       {
  449.          var _loc3_:int = 0;
  450.          var _loc4_:IRepeaterClient = null;
  451.          var _loc5_:int = 0;
  452.          var _loc6_:Repeater = null;
  453.          if(Boolean(mx_internal::createdComponents) && mx_internal::createdComponents.length > 0)
  454.          {
  455.             _loc3_ = int(mx_internal::createdComponents.length - 1);
  456.             while(_loc3_ >= 0)
  457.             {
  458.                _loc4_ = mx_internal::createdComponents[_loc3_];
  459.                _loc5_ = getRepeaterIndex(_loc4_);
  460.                if(param1 <= _loc5_ && (_loc5_ < param2 || param2 == -1) || _loc5_ >= dataProvider.length)
  461.                {
  462.                   if(_loc4_ is Repeater)
  463.                   {
  464.                      _loc6_ = Repeater(_loc4_);
  465.                      removeRepeater(_loc6_);
  466.                   }
  467.                   else if(container.contains(DisplayObject(_loc4_)))
  468.                   {
  469.                      container.removeChild(DisplayObject(_loc4_));
  470.                   }
  471.                   if(_loc4_ is IDeferredInstantiationUIComponent)
  472.                   {
  473.                      IDeferredInstantiationUIComponent(_loc4_).deleteReferenceOnParentDocument(IFlexDisplayObject(parentDocument));
  474.                   }
  475.                   mx_internal::createdComponents.splice(_loc3_,1);
  476.                }
  477.                else if(param1 <= _loc5_ && param2 != -1 && _loc5_ >= param2)
  478.                {
  479.                   adjustIndices(_loc4_,param2 - param1 + 1);
  480.                   if(_loc4_ is IDeferredInstantiationUIComponent)
  481.                   {
  482.                      IDeferredInstantiationUIComponent(_loc4_).executeBindings(true);
  483.                   }
  484.                }
  485.                _loc3_--;
  486.             }
  487.          }
  488.       }
  489.       
  490.       public function set count(param1:int) : void
  491.       {
  492.          _count = param1;
  493.          execute();
  494.          dispatchEvent(new Event("countChanged"));
  495.       }
  496.       
  497.       override public function toString() : String
  498.       {
  499.          return Object(container).toString() + "." + super.toString();
  500.       }
  501.       
  502.       public function executeChildBindings() : void
  503.       {
  504.          var _loc1_:int = 0;
  505.          var _loc2_:int = 0;
  506.          var _loc3_:IRepeaterClient = null;
  507.          _loc1_ = container.numChildren;
  508.          _loc2_ = 0;
  509.          while(_loc2_ < _loc1_)
  510.          {
  511.             _loc3_ = IRepeaterClient(container.getChildAt(_loc2_));
  512.             if(hasDescendant(_loc3_) && _loc3_ is IDeferredInstantiationUIComponent)
  513.             {
  514.                IDeferredInstantiationUIComponent(_loc3_).executeBindings();
  515.             }
  516.             _loc2_++;
  517.          }
  518.       }
  519.       
  520.       private function getRepeaterIndex(param1:IRepeaterClient) : int
  521.       {
  522.          var _loc2_:Array = null;
  523.          var _loc3_:int = 0;
  524.          var _loc4_:int = 0;
  525.          _loc2_ = param1.repeaters;
  526.          if(_loc2_ == null)
  527.          {
  528.             return -1;
  529.          }
  530.          _loc3_ = int(_loc2_.length);
  531.          _loc4_ = 0;
  532.          while(_loc4_ < _loc3_)
  533.          {
  534.             if(_loc2_[_loc4_] == this)
  535.             {
  536.                return param1.repeaterIndices[_loc4_];
  537.             }
  538.             _loc4_++;
  539.          }
  540.          return -1;
  541.       }
  542.       
  543.       private function recycle() : void
  544.       {
  545.          var _loc1_:int = 0;
  546.          var _loc2_:int = 0;
  547.          var _loc3_:int = 0;
  548.          var _loc4_:int = 0;
  549.          var _loc5_:int = 0;
  550.          var _loc6_:int = 0;
  551.          var _loc7_:Repeater = null;
  552.          var _loc8_:IRepeaterClient = null;
  553.          var _loc9_:int = 0;
  554.          var _loc10_:int = 0;
  555.          var _loc11_:IRepeaterClient = null;
  556.          var _loc12_:IRepeaterClient = null;
  557.          dispatchEvent(new FlexEvent(FlexEvent.REPEAT_START));
  558.          _loc1_ = 0;
  559.          _loc5_ = 0;
  560.          if(collection && collection.length > 0 && collection.length - startingIndex > 0)
  561.          {
  562.             _loc1_ = positiveMin(collection.length - startingIndex,count);
  563.             _loc6_ = 0;
  564.             _loc2_ = 0;
  565.             while(_loc2_ < _loc1_)
  566.             {
  567.                _currentIndex = startingIndex + _loc2_;
  568.                dispatchEvent(new FlexEvent(FlexEvent.REPEAT));
  569.                if(childDescriptors)
  570.                {
  571.                   _loc3_ = int(childDescriptors.length);
  572.                   if(mx_internal::createdComponents.length >= (_loc2_ + 1) * _loc3_)
  573.                   {
  574.                      _loc4_ = 0;
  575.                      while(_loc4_ < _loc3_)
  576.                      {
  577.                         _loc8_ = mx_internal::createdComponents[_loc2_ * _loc3_ + _loc4_];
  578.                         if(_loc8_ is Repeater)
  579.                         {
  580.                            _loc7_ = Repeater(_loc8_);
  581.                            resetRepeaterIndices(_loc7_,_currentIndex);
  582.                            _loc7_.owner = this;
  583.                            _loc7_.execute();
  584.                         }
  585.                         else
  586.                         {
  587.                            resetRepeaterIndices(_loc8_,_currentIndex);
  588.                            if(_loc8_ is IDeferredInstantiationUIComponent)
  589.                            {
  590.                               IDeferredInstantiationUIComponent(_loc8_).executeBindings(true);
  591.                            }
  592.                         }
  593.                         _loc5_++;
  594.                         _loc4_++;
  595.                      }
  596.                   }
  597.                   else
  598.                   {
  599.                      _loc4_ = 0;
  600.                      while(_loc4_ < _loc3_)
  601.                      {
  602.                         _loc9_ = container.numChildren;
  603.                         _loc10_ = getIndexForFirstChild() + numCreatedChildren;
  604.                         _loc11_ = IRepeaterClient(createComponentFromDescriptor(_loc2_,_loc4_,true));
  605.                         mx_internal::createdComponents.push(_loc11_);
  606.                         if(_loc11_ is IUIComponent)
  607.                         {
  608.                            IUIComponent(_loc11_).owner = this;
  609.                         }
  610.                         if(_loc11_ is IAutomationObject)
  611.                         {
  612.                            IAutomationObject(_loc11_).showInAutomationHierarchy = true;
  613.                         }
  614.                         if(_loc11_ is Repeater)
  615.                         {
  616.                            _loc7_ = Repeater(_loc11_);
  617.                            _loc7_.reindexDescendants(_loc9_,_loc10_);
  618.                         }
  619.                         else
  620.                         {
  621.                            container.setChildIndex(DisplayObject(_loc11_),_loc10_);
  622.                         }
  623.                         _loc5_++;
  624.                         _loc4_++;
  625.                      }
  626.                   }
  627.                }
  628.                _loc2_++;
  629.             }
  630.          }
  631.          _currentIndex = -1;
  632.          _loc2_ = int(mx_internal::createdComponents.length - 1);
  633.          while(_loc2_ >= _loc5_)
  634.          {
  635.             _loc12_ = mx_internal::createdComponents.pop();
  636.             if(_loc12_ is Repeater)
  637.             {
  638.                removeRepeater(Repeater(_loc12_));
  639.             }
  640.             else if(_loc12_)
  641.             {
  642.                if(_loc12_ is Container)
  643.                {
  644.                   removeAllChildren(Container(_loc12_));
  645.                   removeAllChildRepeaters(Container(_loc12_));
  646.                }
  647.                if(container.contains(DisplayObject(_loc12_)))
  648.                {
  649.                   container.removeChild(DisplayObject(_loc12_));
  650.                }
  651.                if(_loc12_ is IDeferredInstantiationUIComponent)
  652.                {
  653.                   IDeferredInstantiationUIComponent(_loc12_).deleteReferenceOnParentDocument(IFlexDisplayObject(parentDocument));
  654.                }
  655.             }
  656.             _loc2_--;
  657.          }
  658.          dispatchEvent(new FlexEvent(FlexEvent.REPEAT_END));
  659.       }
  660.       
  661.       private function removeChildRepeater(param1:Container, param2:Repeater) : void
  662.       {
  663.          var _loc3_:int = 0;
  664.          var _loc4_:int = 0;
  665.          _loc3_ = 0;
  666.          _loc4_ = int(param1.mx_internal::childRepeaters.length);
  667.          while(_loc3_ < _loc4_)
  668.          {
  669.             if(param1.repeaters[_loc3_] == param2)
  670.             {
  671.                param1.repeaters.splice(_loc3_,1);
  672.                break;
  673.             }
  674.             _loc3_++;
  675.          }
  676.       }
  677.       
  678.       private function getIndexForRepeater(param1:Repeater, param2:LocationInfo) : void
  679.       {
  680.          var _loc3_:int = 0;
  681.          var _loc4_:int = 0;
  682.          var _loc5_:IFlexDisplayObject = null;
  683.          var _loc6_:Repeater = null;
  684.          _loc3_ = 0;
  685.          _loc4_ = int(mx_internal::createdComponents.length);
  686.          while(_loc3_ < _loc4_)
  687.          {
  688.             _loc5_ = mx_internal::createdComponents[_loc3_];
  689.             if(_loc5_ == param1)
  690.             {
  691.                param2.found = true;
  692.                break;
  693.             }
  694.             if(_loc5_ is Repeater)
  695.             {
  696.                _loc6_ = Repeater(_loc5_);
  697.                _loc6_.getIndexForRepeater(param1,param2);
  698.                if(param2.found)
  699.                {
  700.                   break;
  701.                }
  702.             }
  703.             else
  704.             {
  705.                param2.index += 1;
  706.             }
  707.             _loc3_++;
  708.          }
  709.       }
  710.       
  711.       [Bindable("nextRepeaterItem")]
  712.       public function get currentIndex() : int
  713.       {
  714.          if(_currentIndex == -1)
  715.          {
  716.             throw new Error(resourceNotExecuting);
  717.          }
  718.          return _currentIndex;
  719.       }
  720.       
  721.       private function reindexDescendants(param1:int, param2:int) : void
  722.       {
  723.          var _loc3_:int = 0;
  724.          var _loc4_:int = 0;
  725.          var _loc5_:IRepeaterClient = null;
  726.          _loc3_ = container.numChildren - param1;
  727.          _loc4_ = 0;
  728.          while(_loc4_ < _loc3_)
  729.          {
  730.             _loc5_ = IRepeaterClient(container.getChildAt(param1 + _loc4_));
  731.             container.setChildIndex(DisplayObject(_loc5_),param2 + _loc4_);
  732.             _loc4_++;
  733.          }
  734.       }
  735.       
  736.       private function hasDescendant(param1:Object) : Boolean
  737.       {
  738.          var _loc2_:Array = null;
  739.          var _loc3_:int = 0;
  740.          var _loc4_:int = 0;
  741.          _loc2_ = param1.repeaters;
  742.          if(_loc2_ == null)
  743.          {
  744.             return false;
  745.          }
  746.          _loc3_ = int(_loc2_.length);
  747.          _loc4_ = 0;
  748.          while(_loc4_ < _loc3_)
  749.          {
  750.             if(_loc2_[_loc4_] == this)
  751.             {
  752.                return true;
  753.             }
  754.             _loc4_++;
  755.          }
  756.          return false;
  757.       }
  758.       
  759.       public function initializeRepeater(param1:Container, param2:Boolean) : void
  760.       {
  761.          _container = param1;
  762.          descriptorIndex = param1.numChildren;
  763.          created = true;
  764.          if(collection)
  765.          {
  766.             createComponentsFromDescriptors(param2);
  767.          }
  768.          if(owner == null)
  769.          {
  770.             owner = param1;
  771.          }
  772.       }
  773.       
  774.       public function set dataProvider(param1:Object) : void
  775.       {
  776.          var _loc2_:Boolean = false;
  777.          var _loc3_:XMLList = null;
  778.          var _loc4_:Array = null;
  779.          _loc2_ = false;
  780.          if(collection)
  781.          {
  782.             _loc2_ = true;
  783.             collection.removeEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangedHandler);
  784.             collection = null;
  785.             iterator = null;
  786.          }
  787.          if(param1 is Array)
  788.          {
  789.             collection = new ArrayCollection(param1 as Array);
  790.          }
  791.          else if(param1 is ICollectionView)
  792.          {
  793.             collection = ICollectionView(param1);
  794.          }
  795.          else if(param1 is IList)
  796.          {
  797.             collection = new ListCollectionView(IList(param1));
  798.          }
  799.          else if(param1 is XMLList)
  800.          {
  801.             collection = new XMLListCollection(param1 as XMLList);
  802.          }
  803.          else if(param1 is XML)
  804.          {
  805.             _loc3_ = new XMLList();
  806.             _loc3_ += param1;
  807.             collection = new XMLListCollection(_loc3_);
  808.          }
  809.          else if(param1 != null)
  810.          {
  811.             _loc4_ = [param1];
  812.             collection = new ArrayCollection(_loc4_);
  813.          }
  814.          if(collection)
  815.          {
  816.             collection.addEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangedHandler,false,0,true);
  817.             iterator = collection.createCursor();
  818.          }
  819.          dispatchEvent(new Event("collectionChange"));
  820.          if(Boolean(collection) || _loc2_)
  821.          {
  822.             execute();
  823.          }
  824.       }
  825.       
  826.       public function set recycleChildren(param1:Boolean) : void
  827.       {
  828.          _recycleChildren = param1;
  829.       }
  830.       
  831.       private function responderResultHandler(param1:Object, param2:Object) : void
  832.       {
  833.          execute();
  834.       }
  835.       
  836.       private function execute() : void
  837.       {
  838.          if(!created)
  839.          {
  840.             return;
  841.          }
  842.          if(recycleChildren && mx_internal::createdComponents && mx_internal::createdComponents.length > 0)
  843.          {
  844.             recycle();
  845.          }
  846.          else
  847.          {
  848.             recreate();
  849.          }
  850.       }
  851.       
  852.       private function removeAllChildren(param1:Container) : void
  853.       {
  854.          var _loc2_:int = 0;
  855.          var _loc3_:int = 0;
  856.          var _loc4_:IRepeaterClient = null;
  857.          _loc2_ = param1.numChildren;
  858.          _loc3_ = _loc2_ - 1;
  859.          while(_loc3_ >= 0)
  860.          {
  861.             _loc4_ = IRepeaterClient(param1.getChildAt(_loc3_));
  862.             if(hasDescendant(_loc4_))
  863.             {
  864.                if(_loc4_ is Container)
  865.                {
  866.                   removeAllChildren(Container(_loc4_));
  867.                   removeAllChildRepeaters(Container(_loc4_));
  868.                }
  869.                param1.removeChildAt(_loc3_);
  870.                if(_loc4_ is IDeferredInstantiationUIComponent)
  871.                {
  872.                   IDeferredInstantiationUIComponent(_loc4_).deleteReferenceOnParentDocument(IFlexDisplayObject(parentDocument));
  873.                }
  874.             }
  875.             _loc3_--;
  876.          }
  877.       }
  878.       
  879.       private function addItems(param1:int, param2:int) : void
  880.       {
  881.          var _loc3_:int = 0;
  882.          var _loc4_:int = 0;
  883.          var _loc5_:int = 0;
  884.          var _loc6_:IRepeaterClient = null;
  885.          var _loc7_:int = 0;
  886.          var _loc8_:int = 0;
  887.          var _loc9_:int = 0;
  888.          var _loc10_:int = 0;
  889.          var _loc11_:int = 0;
  890.          var _loc12_:int = 0;
  891.          var _loc13_:IFlexDisplayObject = null;
  892.          var _loc14_:Repeater = null;
  893.          if(startingIndex > param2)
  894.          {
  895.             return;
  896.          }
  897.          _loc4_ = -1;
  898.          _loc5_ = container.numChildren;
  899.          if(param2 == collection.length - 1)
  900.          {
  901.             _loc3_ = _loc5_ - 1;
  902.             while(_loc3_ >= 0)
  903.             {
  904.                _loc6_ = IRepeaterClient(container.getChildAt(_loc3_));
  905.                _loc7_ = getRepeaterIndex(_loc6_);
  906.                if(_loc7_ != -1)
  907.                {
  908.                   _loc4_ = _loc3_ + 1;
  909.                   break;
  910.                }
  911.                _loc3_--;
  912.             }
  913.          }
  914.          else
  915.          {
  916.             _loc8_ = param2 - param1 + 1;
  917.             _loc3_ = 0;
  918.             while(_loc3_ < _loc5_)
  919.             {
  920.                _loc6_ = IRepeaterClient(container.getChildAt(_loc3_));
  921.                _loc7_ = getRepeaterIndex(_loc6_);
  922.                if(_loc7_ != -1)
  923.                {
  924.                   if(param1 <= _loc7_ && _loc7_ <= param2 && _loc4_ == -1)
  925.                   {
  926.                      _loc4_ = _loc3_;
  927.                   }
  928.                   if(_loc7_ >= param1)
  929.                   {
  930.                      adjustIndices(_loc6_,_loc8_);
  931.                   }
  932.                }
  933.                _loc3_++;
  934.             }
  935.          }
  936.          if(count == -1)
  937.          {
  938.             _loc5_ = param2;
  939.          }
  940.          else
  941.          {
  942.             _loc5_ = positiveMin(startingIndex + count - 1,param2);
  943.          }
  944.          _loc3_ = Math.max(startingIndex,param1);
  945.          while(_loc3_ <= _loc5_)
  946.          {
  947.             _loc9_ = int(childDescriptors.length);
  948.             _currentIndex = _loc3_;
  949.             dispatchEvent(new FlexEvent(FlexEvent.REPEAT));
  950.             _loc10_ = 0;
  951.             while(_loc10_ < _loc9_)
  952.             {
  953.                _loc11_ = container.numChildren;
  954.                _loc12_ = getIndexForFirstChild() + numCreatedChildren;
  955.                _loc13_ = createComponentFromDescriptor(_loc3_ - startingIndex,_loc10_,true);
  956.                mx_internal::createdComponents.push(_loc13_);
  957.                if(_loc13_ is IUIComponent)
  958.                {
  959.                   IUIComponent(_loc13_).owner = this;
  960.                }
  961.                if(_loc13_ is IAutomationObject)
  962.                {
  963.                   IAutomationObject(_loc13_).showInAutomationHierarchy = true;
  964.                }
  965.                if(_loc13_ is Repeater)
  966.                {
  967.                   _loc14_ = Repeater(_loc13_);
  968.                   _loc14_.owner = this;
  969.                   _loc14_.reindexDescendants(_loc11_,_loc12_);
  970.                }
  971.                else
  972.                {
  973.                   container.setChildIndex(DisplayObject(_loc13_),_loc12_);
  974.                }
  975.                _loc10_++;
  976.             }
  977.             _loc3_++;
  978.          }
  979.          _currentIndex = -1;
  980.       }
  981.       
  982.       [Bindable("collectionChange")]
  983.       public function get dataProvider() : Object
  984.       {
  985.          return collection;
  986.       }
  987.    }
  988. }
  989.  
  990. class LocationInfo
  991. {
  992.    public var found:Boolean = false;
  993.    
  994.    public var index:int = 0;
  995.    
  996.    public function LocationInfo()
  997.    {
  998.       found = false;
  999.       index = 0;
  1000.       super();
  1001.    }
  1002. }
  1003.